package com.lch.designpattern.strategy.pay.payport;

import com.lch.designpattern.strategy.pay.MsgResult;
import com.lch.designpattern.strategy.pay.PayTypeEnum;

/**
 * @author: liuchenhui
 * @create: 2019-06-23 12:38
 **/
public class AliPay extends Payment {
    @Override
    public String getName() {
        return PayTypeEnum.ALIPAY.name();
    }

    @Override
    public int getBalance(String uid) {
        return 500;
    }

    @Override
    public MsgResult pay(String uid, int amount) {
        System.out.println("支付宝开始支付");
        if (getBalance(uid) < amount) {
            return MsgResult.builder().msg("支付失败，余额不足").code(500).build();
        }
        System.out.println("开始支付，扣款" + amount);
        return MsgResult.builder().msg("支付成功").code(200).build();
    }
}
